home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / cafead1a / resoluti.bas < prev    next >
Encoding:
BASIC Source File  |  1999-10-05  |  2.2 KB  |  84 lines

  1. Attribute VB_Name = "Resolution"
  2. Option Explicit
  3. 'This module is a modified Microsoft example and was
  4. 'written by Newton Stamper.
  5. Public Xtwips As Integer, Ytwips As Integer
  6. Public Xpixels As Integer, Ypixels As Integer
  7.  
  8. Type FRMSIZE
  9.    Height As Long
  10.    Width As Long
  11. End Type
  12.  
  13. Public RePosForm As Boolean
  14. Public DoResize As Boolean
  15. Dim MyForm As FRMSIZE
  16. Dim DesignX As Integer
  17. Dim DesignY As Integer
  18. Dim ScaleFactorX As Single, ScaleFactorY As Single
  19.  
  20.  
  21. Sub Resize_For_Resolution(ByVal SFX As Single, ByVal SFY As Single, MyForm As Form)
  22. Dim I As Integer
  23. Dim SFFont As Single
  24. SFFont = (SFX + SFY) / 2
  25. On Error Resume Next
  26. With MyForm
  27.   For I = 0 To .Count - 1
  28.    If TypeOf .Controls(I) Is ComboBox Then
  29.      .Controls(I).Left = .Controls(I).Left * SFX
  30.      .Controls(I).Top = .Controls(I).Top * SFY
  31.      .Controls(I).Width = .Controls(I).Width * SFX
  32.    Else
  33.      .Controls(I).Move .Controls(I).Left * SFX, _
  34.       .Controls(I).Top * SFY, _
  35.       .Controls(I).Width * SFX, _
  36.       .Controls(I).Height * SFY
  37.    End If
  38.      .Controls(I).FontSize = .Controls(I).FontSize * SFFont
  39.   Next I
  40.   If RePosForm Then
  41.      .Move .Left * SFX, .Top * SFY, .Width * SFX, .Height * SFY
  42.   End If
  43. End With
  44. End Sub
  45.  
  46.  
  47. Public Sub FormResize(TheForm As Form)
  48. Dim ScaleFactorX As Single, ScaleFactorY As Single
  49. If Not DoResize Then
  50.    DoResize = True
  51.    Exit Sub
  52. End If
  53. RePosForm = False
  54. ScaleFactorX = TheForm.Width / MyForm.Width
  55. ScaleFactorY = TheForm.Height / MyForm.Height
  56. Resize_For_Resolution ScaleFactorX, ScaleFactorY, TheForm
  57. MyForm.Height = TheForm.Height
  58. MyForm.Width = TheForm.Width
  59. End Sub
  60.  
  61. Public Sub AdjustForm(TheForm As Form)
  62. Dim Res As String ' Returns resolution of system
  63. ' Put the design time resolution in here
  64. DesignX = 640
  65. DesignY = 480
  66. RePosForm = True
  67. DoResize = False
  68. Xtwips = Screen.TwipsPerPixelX
  69. Ytwips = Screen.TwipsPerPixelY
  70. Ypixels = Screen.Height / Ytwips
  71. Xpixels = Screen.Width / Xtwips
  72. ScaleFactorX = (Xpixels / DesignX)
  73. ScaleFactorY = (Ypixels / DesignY)
  74. TheForm.ScaleMode = 1
  75. Resize_For_Resolution ScaleFactorX, ScaleFactorY, TheForm
  76. Res = Str$(Xpixels) + "  by " + Str$(Ypixels)
  77. Debug.Print Res
  78. MyForm.Height = TheForm.Height
  79. MyForm.Width = TheForm.Width
  80.  
  81. End Sub
  82.  
  83.  
  84.